
/* 日期格式化 */
export function formatTime(time, format = '') {
    let str = '';

    if (!time || time == 0) {
        str = '';
    } else {
        let date = new Date(Number(time));
        let y = date.getFullYear();
        let m = (date.getMonth() + 1).toString().padStart(2, '0');
        let d = date.getDate().toString().padStart(2, '0');
        let h = date.getHours().toString().padStart(2, '0');
        let i = date.getMinutes().toString().padStart(2, '0');
        let s = date.getSeconds().toString().padStart(2, '0');

        if (format === 'y-m-d h:i') {
            str = y + '-' + m + '-' + d + ' ' + h + ':' + i;
        } else if (format == 'y-m-d h:i:s') {
            str = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
        } else if (format === 'y-m-d') {
            str = y + '-' + m + '-' + d;
        } else if (format === 'y') {
            str = y;
        } else if (format === 'y-m') {
            str = y + '-' + m;
        } else if (format === 'ymd') {
            str = y + '' + m + '' + d;
        } else if (format === 'd') {
            str = d;
        } else if (format === 'h:i') {
            str = h + ':' + i;
        } else if (format === 'h') {
            str = h;
        } else {
            str = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
        }
    }

    return str;
}

/*-------------------------------------------------------------------------------------
 | 系统设置
 |-------------------------------------------------------------------------------------
 */
/**
 * 菜单管理-类型，1-分类，2-菜单，3-按钮，4-动作
 */
export function systemMenuTypeToStr(value) {
    let str = '';

    if (value == 1) {
        str = '分类';
    } else if (value == 2) {
        str = '菜单';
    } else if (value == 3) {
        str = '按钮';
    } else if (value == 4) {
        str = '动作';
    }

    return str;
}